home *** CD-ROM | disk | FTP | other *** search
- Path: diku.dk!diku2471
- From: diku2471@diku.dk (ASGER ALSTRUP NIELSEN)
- Newsgroups: comp.sys.cbm
- Subject: Re: anyone doing heavy math on a c64?
- Date: 17 Feb 1996 19:43:28 GMT
- Organization: Department of Computer Science, U of Copenhagen
- Sender: diku2471@fjalar.diku.dk
- Message-ID: <4g5b50$70h@odin.diku.dk>
- References: <4e2l0q$n8f@turing.fwi.uva.nl> <4f49t9$2q5@madeline.INS.CWRU.Edu> <4fchhs$2r1@tor.abc.se> <4ftcnm$bfs@news.acns.nwu.edu> <DMsHCw.8G0@undergrad.math.uwaterloo.ca>
- NNTP-Posting-Host: odin.diku.dk
- X-Newsreader: NN version 6.5.0 #13
-
- csbruce@ccnga.uwaterloo.ca (Craig Bruce) writes:
-
- >In article <4ftcnm$bfs@news.acns.nwu.edu>, Stephen Judd <sjudd@nwu.edu> wrote:
-
- >>Peter T Karlsson <dat95pkn@idt.mdh.se> wrote:
- >>>C=64+64*INT(.1+.9)
- >>>
- >>>will give C 64 for a C64 and 128 on a C128!
- >>
- >>I find this very interesting. Does anyone have an explanation for this?
-
- >Floating-point arithmetic is a bit of a crap shoot anyway. Maybe they subtly
- >changed the addition code between the two versions, or...
-
- Maybe, but I doubt the change is the addition code as such. It is probably
- in some internal rounding function instead, see below.
-
- >I have some vague notions about the floating-point accumulators (FACs)
- >storing a number with slightly more precision than a floating-point
- >variable, so this may be what is happening. If the number doesn't have to
- >leave the FACs (which it doesn't in the above first example), then there may
- >be a slightly different answer from if it does. Maybe the C128 stores or
- >doesn't store intermediate results from the FACs while the C64 doesn't/
- >does.
-
- I think, I remember that the floating point routines are bugged. It's correct
- that it uses higher precision when calculating than when storing, but the
- lsbs of the FACs aren't always reset properly between operations, so you
- can have situations where the same arithmetical expression yields
- different results depending on what the lsbs of the FACs contain at that
- particular point. Maybe they fixed the initialization bug in the c128 rom
- and this could explain the difference.
-
- Other than that, the floating point operations of the c64 are not exactly
- the best in the business, but they candidate for the smallest in bytes.
- The coders did a lot of tricks to pack up all that functionality into such
- small space. This affects performance: For instance, the sqr() function
- is calculated as x^0.5, which is a far shot from a fast method. If you
- use sqr a lot, it pays a lot to use a custom routine. The german magazine
- 64er once held a contest to find the best sqr-routine, and the winner used
- a lookup table to give a start-value for a newton-ralphson search and was
- many times faster than the original code besides a lot more precise, and
- still around 256 bytes in size. The guys behind the basic rom simply didn't
- have those 256 bytes to do it better, and then again, they would probably
- have crammed another function in instead of a faster squareroot ;-)
-
- Greets,
-
- Asger Alstrup.
-